<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录 - CRM系统</title>
    <link rel="stylesheet" th:href="@{/css/style.css}">
    <style>
        body {
            background-color: var(--background-color);
            font-family: 'Segoe UI', 'Roboto', Arial, sans-serif;
        }
        
        .toast {
            position: fixed;
            top: 20px;
            right: 20px;
            min-width: 250px;
            padding: 16px;
            border-radius: 6px;
            background-color: var(--primary-color);
            color: white;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
            z-index: 1000;
            transition: transform 0.3s, opacity 0.3s;
            transform: translateY(-20px);
            opacity: 0;
        }
        
        .toast.show {
            transform: translateY(0);
            opacity: 1;
        }
        
        .toast-success {
            background-color: var(--success-color);
        }
        
        .toast-error {
            background-color: var(--danger-color);
        }
        
        .toast-info {
            background-color: var(--info-color);
        }
        
        .invalid-feedback {
            display: block;
            width: 100%;
            margin-top: 0.25rem;
            font-size: 80%;
            color: var(--danger-color);
        }
        
        .is-invalid {
            border-color: var(--danger-color);
        }
        
        .alert {
            padding: 0.75rem 1.25rem;
            margin-bottom: 1rem;
            border: 1px solid transparent;
            border-radius: 0.25rem;
        }
        
        .alert-danger {
            color: #721c24;
            background-color: #f8d7da;
            border-color: #f5c6cb;
        }
        
        .alert-success {
            color: #155724;
            background-color: #d4edda;
            border-color: #c3e6cb;
        }
    </style>
</head>
<body>
    <div class="login-container">
        <div class="login-card">
            <div class="login-header">
                <h1 class="login-title">CRM系统</h1>
            </div>
            <div class="login-body">
                <div th:if="${param.error}" class="alert alert-danger mb-3">
                    用户名或密码错误，请重试。
                </div>
                <div th:if="${param.logout}" class="alert alert-success mb-3">
                    您已成功登出。
                </div>
                <form th:action="@{/login}" method="post" id="loginForm" data-validate="true">
                    <div class="form-group">
                        <label for="username" class="form-label">用户名</label>
                        <input type="text" id="username" name="username" class="form-control" required autofocus>
                    </div>
                    <div class="form-group">
                        <label for="password" class="form-label">密码</label>
                        <input type="password" id="password" name="password" class="form-control" required>
                    </div>
                    <div class="form-group">
                        <div class="d-flex justify-content-between align-items-center">
                            <div>
                                <input type="checkbox" id="remember-me" name="remember-me">
                                <label for="remember-me">记住我</label>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <button type="submit" class="btn btn-primary" style="width: 100%;">登录</button>
                    </div>
                </form>
                <div class="mt-3 text-center">
                    <small>默认用户名: admin, 密码: 123456</small>
                </div>
            </div>
            <div class="login-footer">
                <p>© 2023 CRM系统 版权所有</p>
            </div>
        </div>
    </div>
    
    <script th:src="@{/js/main.js}"></script>
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            initFormValidation();
            
            // 参数判断显示提示信息
            const urlParams = new URLSearchParams(window.location.search);
            if (urlParams.has('error')) {
                showToast('用户名或密码错误，请重试。', 'error');
            }
            if (urlParams.has('logout')) {
                showToast('您已成功登出。', 'success');
            }
        });
    </script>
</body>
</html> 